<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>2350300097 万朗</title>
</head>
<body>
<%
    request.setCharacterEncoding("UTF-8");
    String teacherName=(String)session.getAttribute("teacherName");
    String className=(String)session.getAttribute("className");
    String courseNum=(String)session.getAttribute("courseNum");
    String studentNum=(String)session.getAttribute("studentNum");
    int cn=Integer.parseInt(courseNum);
    int sn=Integer.parseInt(studentNum);

    String[] courseName=(String[])session.getAttribute("courseName");
    String[] studentName=new String[sn];
    int score[][]=new int[sn][cn];
    int sum[]=new int[sn];
    int ave[]=new int[sn];

    for(int i=0;i<sn;i++){
        studentName[i]=request.getParameter("studentName["+i+"]");
        for(int j=0;j<cn;j++){
            score[i][j]=Integer.parseInt(request.getParameter("score["+i+"]["+j+"]"));
            sum[i]+=score[i][j];
        }
        ave[i]=sum[i]/cn;
    }

%>
<p align="center"><strong><font size="5">学生成绩单</font></strong></p>
<hr width="600">
<p align="center"><strong>
    老师姓名：<%=teacherName %>&nbsp;&nbsp;
    班级名称：<%=className %>&nbsp;&nbsp;
    学生人数：<%=courseNum %>&nbsp;&nbsp;
    科目数：<%=studentNum %>
</strong></p>
<table border="0" align="center" cellpadding="2" cellspacing="0">
    <tr bgcolor="#99FFFF">
        <td align="center"><strong>学生姓名</strong></td>
        <%for(int i=0;i<cn;i++){ %>
        <td align="center"><strong><font color="#FF0000"><%=courseName[i] %></
            font>成绩</strong></td>
        <%} %>
        <td align="center"><strong>总分</strong></td>
        <td align="center"><strong>平均分</strong></td>
    </tr>
    <%for(int i=0;i<sn;i++){ %>
    <tr bgcolor="#99FFFF">
        <td align="center"><%=studentName[i] %></td>
        <%for(int j=0;j<cn;j++){ %>
        <td align="center"><%=score[i][j] %></td>
        <%} %>
        <td align="center"><%=sum[i] %></td>
        <td align="center"><%=ave[i] %></td>
    </tr>
    <%} %>
</table>
<p>&nbsp;</p>
</body>
</html>